//
//  DiseasesTableViewCell.m
//  WE
//
//  Created by iMacOne on 15/11/18.
//  Copyright © 2015年 UNOHACHA. All rights reserved.
//

#import "DiseasesTableViewCell.h"
#import "Head.h"
#import "SectionsViewController.h"
@implementation DiseasesTableViewCell



- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        
        self.aImgeView = [[UIImageView alloc] initWithFrame:CGRectMake(margin_5 * Width, margin_10 * Height, margin_20 , margin_20)];
        _aImgeView.layer.masksToBounds = YES;
        _aImgeView.layer.cornerRadius = 10;
        _aImgeView.image = [UIImage imageNamed:@"changjian"];
        _aImgeView.backgroundColor = [UIColor colorWithRed:0.2408 green:0.7356 blue:0.2248 alpha:1.0];
        
        self.disLabel = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(_aImgeView.frame) + margin_5 * Width, _aImgeView.frame.origin.y, margin_64, _aImgeView.frame.size.height)];
        _disLabel.font = FONT(14);
        _disLabel.text = @"常见疾病";
        
        self.moreLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, margin_30, margin_10)];
        _moreLabel.text = @"更多";
        _moreLabel.font = FONT(10);
        _moreLabel.textColor = [UIColor grayColor];
//        _moreLabel.backgroundColor = [UIColor cyanColor];
        
        self.chooseImgeView = [[UIImageView alloc] initWithFrame:CGRectMake(CGRectGetMaxX(_moreLabel.frame) - 5, _moreLabel.frame.origin.y - 2, margin_15, margin_15)];
//        _chooseImgeView.backgroundColor = DEBUG_CLOLR;
        _chooseImgeView.image = [UIImage imageNamed:@"zanting"];
        self.moreButton = [UIButton buttonWithType:UIButtonTypeCustom];
        _moreButton.frame = CGRectMake(WindowWidth - margin_64, _aImgeView.frame.origin.y, margin_48, _aImgeView.frame.size.height);
        [_moreButton addTarget:self action:@selector(doClickButton:) forControlEvents:UIControlEventTouchUpInside];
        _moreButton.tag = 300;
//        _moreButton.backgroundColor = [UIColor yellowColor];
        [_moreButton addSubview:_moreLabel];
        [_moreButton addSubview:_chooseImgeView];
//
        NSArray * array = [NSArray arrayWithObjects:@"霍纳",@"中耳炎",@"扁桃全体",@"综合征", nil];
        NSArray * array1 = [NSArray arrayWithObjects:@"溃性结肠炎",@"十二指肠溃疡",@"综合征", nil];
        for (int i = 0; i < 4; i++) {
            UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom];
//            float y = [ToolUtil autoWidth:@"weiieeijljlkjklkj" width:0 height:margin_20 num:12];
            
            button.frame = CGRectMake(margin_10*(i + 1) + i * (WindowWidth - 50)/4, CGRectGetMaxY(self.disLabel.frame) + margin_20, (WindowWidth - 50)/4, margin_20);
            [button addTarget:self action:@selector(doClickButton:) forControlEvents:UIControlEventTouchUpInside];
//            button.backgroundColor = DEBUG_CLOLR;
            button.tag = 100 + i;
            [button setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
            button.layer.borderWidth = 0.5;
            button.layer.masksToBounds = YES;
            button.layer.cornerRadius = 2;
            button.layer.borderColor = [UIColor grayColor].CGColor;
            button.titleLabel.font = FONT(12);
            [button setTitle:array[i] forState:UIControlStateNormal];
            [self.contentView addSubview:button];
        }
        for (int i = 0; i < 3; i++) {
            UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom];
//            float y = [ToolUtil autoWidth:@"weiieeijljlkjklkj" width:0 height:margin_20 num:12];
            if (i == 2) {
                button.frame = CGRectMake(40 + 3 * (WindowWidth - 50)/4, CGRectGetMaxY(self.disLabel.frame) + margin_48, (WindowWidth - 50)/4, margin_20);
            }else{
            button.frame = CGRectMake(10 *(i + 1) + i * (margin_10 + 3 * (WindowWidth - 50)/4)/2, CGRectGetMaxY(self.disLabel.frame) + margin_48, (margin_10 + 3 * (WindowWidth - 50)/4)/2, margin_20);
            }
            button.tag = 200 + i;
            [button addTarget:self action:@selector(doClickButton:) forControlEvents:UIControlEventTouchUpInside];
//            button.backgroundColor = DEBUG_CLOLR;
            button.titleLabel.font = FONT(12);
            [button setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
            button.layer.borderWidth = 0.5;
            button.layer.masksToBounds = YES;
            button.layer.cornerRadius = 2;
            button.layer.borderColor = [UIColor grayColor].CGColor;
            [button setTitle:array1[i] forState:UIControlStateNormal];
            [self.contentView addSubview:button];
            

        }
        
        [self.contentView addSubview:_aImgeView];
        [self.contentView addSubview:_disLabel];
        [self.contentView addSubview:_moreButton];
        
        
        
    }
    return self;
}

- (void)doClickButton:(UIButton *)btn
{
    
    [self.delegate doClickBtn:btn.tag cell:self];
}
@end
